from optparse import OptionParser
from tparser.control.populate import Populate
from tparser.view.cmdline import CmdLine


def init_parser():
    parser = OptionParser()
    parser.set_defaults(
        create=False,
        data='trips.csv',
        db='sqlite:///tp.db',
        format='extended',
        schema=None,
    )
    parser.add_option(
        "-c", "--create", action="store_true", dest="create",
        help="Create database tables"
    )
    parser.add_option(
        "-d", "--database", dest="db",
        help="Database connection string for engine"
    )
    parser.add_option(
        "-f", "--csv", dest="data",
        help="CSV file name for trip parameters"
    )
    parser.add_option(
        "-s", "--schema", dest="schema",
        help="Optional database schema name"
    )
    (options, args) = parser.parse_args()
    return options


def main():
    options = init_parser()
    c = Populate(options)
    c.load_tm_od_study('SubSet_2000-2006-OD.csv')
    v = CmdLine(c)

if __name__ == '__main__':
    main()
